package cn.yhz.pethome.base.service.impl;



import cn.yhz.pethome.base.mapper.BaseMapper;
import cn.yhz.pethome.base.service.IBaseService;
import cn.yhz.pethome.base.util.BaseQuery;
import cn.yhz.pethome.base.util.ResultBean;
import cn.yhz.pethome.dept.domain.Department;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Transactional(readOnly = true,propagation = Propagation.SUPPORTS)
public class BaseServiceImpl<T> implements IBaseService<T> {
    @Autowired
    private BaseMapper<T> baseMapper;
    @Override
    public ResultBean queryAll(BaseQuery query) {
        ResultBean result = new ResultBean<>();
        result.setTotal(baseMapper.selectCountAll(query));
        result.setPageList(baseMapper.selectQuery(query));
        return result;
    }

    @Override
    public T selectById(Long id) {
        return baseMapper.selectById(id);
    }

    @Override
    public void insert(T t) {
        baseMapper.insert(t);
    }

    @Override
    public void update(T t) {
        baseMapper.update(t);
    }

    @Override
    public void delete(Long id) {
        baseMapper.delete(id);
    }

    @Override
    public void batchDelete(List<Long> ids) {
        baseMapper.batchDelete(ids);
    }
}
